package com.hmy.infrastructure.common.config;

import com.aliyun.push20160801.Client;
import com.aliyun.teaopenapi.models.Config;
import com.hmy.infrastructure.common.properties.AliEMASPushProperties;
import javax.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author : wenjian
 * @version : v1.0
 * @description : 阿里云EMAS 移动推送消息
 * @date : 2024/2/29 20:31
 */
@Configuration
public class AliEmasConfig {

    @Resource
    private AliEMASPushProperties aliEMASPushProperties;

    @Bean
    public Client initClient() throws Exception {
        Config config = new Config()
                // AccessKey ID
                .setAccessKeyId(aliEMASPushProperties.getAccessKeyId())
                .setRegionId(aliEMASPushProperties.getRegionId())
                // AccessKey Secret
                .setAccessKeySecret(aliEMASPushProperties.getAccessKeySecret());
        // 访问的域名
        config.endpoint = "cloudpush.aliyuncs.com";
        return new Client(config);
    }

}
